// 不想再写一次最小生成树.jpg

#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const int N = 1010;
int a[N], b[N];
int par[25010];
int find(int x) { return par[x] = x == par[x] ? x : find(par[x]); }
struct ed {
  int u, v;
  ll w;
  bool operator<(const ed &b) const { return w < b.w; }
};
ll dist(int i, int j) {
  ll dx = a[i] - a[j];
  ll dy = b[i] - b[j];
  return dx * dx + dy * dy;
}
vector<ed> E;
int n;
int main() {
  for (int i = 0; i <= 25000; ++i) par[i] = i;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a[i] >> b[i];
  }
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      E.push_back({i, j, dist(i, j)});
    }
  }
  sort(E.begin(), E.end());

  int sel = 0;
  for (auto [u, v, w] : E) {
    u = find(u);
    v = find(v);
    if (u == v) continue;
    par[u] = v;
    sel++;
    if (sel == n - 1) {
      cout << w << endl;
      return 0;
    }
  }
}
